<template>
	<view class="main_bg">
		<app-header title="设置与隐私"></app-header>
		<view style="height: 1px;"></view>
		<view class="cells">
			<u-cell title="个人信息" isLink size="large" url="/pages/setting/info"></u-cell>
			<u-cell title="用户协议" isLink size="large" url="/pages/article/article?id=1"></u-cell>
			<u-cell title="隐私政策" isLink size="large" url="/pages/article/article?id=2"></u-cell>
			<u-cell title="关于我们" isLink size="large" url="/pages/article/article?id=3"></u-cell>
			<u-cell title="版本号" :border="false" size="large" :value="'V'+version"></u-cell>
		</view>
		<view class="btn flex-c" @click="logout()">退出登录</view>
	</view>
</template>

<script>
	import { removeToken } from '@/utils/auth'
	export default {
		data() {
			return {

			}
		},
		computed:{
			version(){
				const miniProgram  = wx.getAccountInfoSync();
				return miniProgram.miniProgram.version || '1.0.0';
			}
		},
		methods: {
			logout() {
				uni.showModal({
					title: '提示',
					content: '确定退出登录吗？',
					confirmText: "确定",
					cancelText: "取消",
					success: (res) => {
						if (res.confirm) {

							this.$http.post('/data/api.auth.User/exit').then(res => {
								uni.hideToast()
							}).catch(e => {
								uni.hideToast()
							})
							this.$store.commit("SET_INFO", {})
							this.$store.commit("SET_TOKEN", null)
							removeToken()
							uni.reLaunch({
								url: '/pages/login/index'
							});


						} else if (res.cancel) {

						}
					}
				});

			}
		}
	}
</script>

<style scoped lang="scss">
	.btn {
		position: fixed;
		left: 40rpx;
		right: 40rpx;
		bottom: 50rpx;
		height: 80rpx;
		background-color: #4F6FF6;
		border-radius: 10rpx;
		font-size: 30rpx;

		color: #FFFFFF;
		margin: 40rpx 0;
	}

	.cells {
		border-radius: 8px;
		background-color: #FFFFFF;
		overflow: hidden;
		margin: 30rpx;
	}
</style>